package loving;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ValidateController{
    
	private boolean checkLogin(HttpServletRequest request, HttpServletResponse response){
		String uName = request.getParameter("uName");
		String password = request.getParameter("password");
		if ("nana".equals(uName) && "2014927".equals(password)) {
			return true;
		}else {
			return false;
		}
	}
	
	@RequestMapping("/index")
	public String index(HttpServletRequest request, HttpServletResponse response) throws IOException{
		if (!checkLogin(request, response)) {
			response.sendRedirect("login.jsp");
		}
		return "index";
	}
}
